﻿using System;
using System.IO;
    
class CompareTwoTextFiles
{
    static void CompareFiles(string file1, string file2)
    {
        StreamReader strR1 = new StreamReader(file1);
        StreamReader strR2 = new StreamReader(file2);
        int counterEqual = 0;
        int counterDifferent = 0;
        using (strR1)
        {
            using (strR2)
            {
                string readedLine1 = strR1.ReadLine();
                string readedLine2 = strR2.ReadLine();
                while (readedLine1 != null && readedLine2 != null)
                {
                    if (readedLine1 == readedLine2)
                    {
                        counterEqual++;
                    }
                    else
                    {
                        counterDifferent++;
                    }
                    readedLine1 = strR1.ReadLine();
                    readedLine2 = strR2.ReadLine();
                }
            }
        }
        Console.WriteLine("Numbers of equal lines: {0}",counterEqual);
        Console.WriteLine("Number of different lines: {0}",counterDifferent);
    }
    static void Main()
    {
        StreamReader readFirstFile = new StreamReader("firstfile.txt");
        using(readFirstFile)
        {
            string lineReaded = readFirstFile.ReadLine();
            Console.WriteLine("The content of the first file is:");
            while(lineReaded != null)
            {
                Console.WriteLine(lineReaded);
                lineReaded = readFirstFile.ReadLine();
            }
        }

        Console.WriteLine();
        StreamReader readSecondFile = new StreamReader("secondfile.txt");
        using (readSecondFile)
        {

            string lineReaded = readSecondFile.ReadLine();
            Console.WriteLine("The content of the second file is:");
            while (lineReaded != null)
            {
                Console.WriteLine(lineReaded);
                lineReaded = readSecondFile.ReadLine();
            }
        }
        Console.WriteLine();
        Console.WriteLine();
        CompareFiles("firstfile.txt", "secondfile.txt");
    }
}

